package com.example.presentshopping.ui.activity

import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import com.example.presentshopping.R
import com.example.presentshopping.config.base.BaseMvpActivity
import com.example.presentshopping.exent.PromoteOrderExent
import com.example.presentshopping.ui.fragment.TeamAwardFragment
import com.example.presentshopping.exent.UserEvent

import kotlinx.android.synthetic.main.activity_team_award.*
import kotlinx.android.synthetic.main.activity_team_award.SpecialViewPager
import kotlinx.android.synthetic.main.activity_team_award.tablayout
import kotlinx.android.synthetic.main.activity_team_award.title_main_tv
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe


class TeamAwardActivity : BaseMvpActivity() {
    private val strTitle = arrayOf("推荐收益", "管理收益")


    override val layoutId: Int
        get() = R.layout.activity_team_award

    override fun initView(savedInstanceState: Bundle?) {
        EventBus.getDefault().register(this)
        title_main_tv.leftBackImageTv.setOnClickListener { finish() }
        val pageViews = ArrayList<Fragment>()
        pageViews.add(TeamAwardFragment("1"))
        pageViews.add(TeamAwardFragment("2"))
        tablayout.setViewPager(SpecialViewPager,strTitle,this,pageViews)

        val  intswe = Intent(this,EarningsActivity().javaClass)

        amount_lvt?.setOnClickListener {
            intswe.putExtra("teleText","推荐收益")
            startActivity(intswe)
        }
        team_amoun_ly?.setOnClickListener {
            intswe.putExtra("teleText","管理收益")
            startActivity(intswe)
        }


    }
    @Subscribe
    fun onEventMainThread(event : PromoteOrderExent){
        balance_textview_01.text =event.total_amount.toString()
        balance_textview_02.text =event.second_amount.toString()
        balance_textview_03.text =event.yestday_amount.toString()
        balance_textview_04.text =event.team_amount.toString()


    }


    override fun onDestroy() {
        super.onDestroy()
        EventBus.getDefault().unregister(this)
    }
    override fun showToast(msg: String?) {

    }

    override fun onSuccess(data: String?) {
//        prom= GsonUtils.getGson()?.fromJson(data, PromoteOrderBean().javaClass)
//        balance_textview_01.text =prom?.data?.total_amount.toString()
//        balance_textview_07.text =prom?.data?.second_amount.toString()
//        balance_textview_08.text =prom?.data?.team_amount.toString()
//        balance_textview_05.text = prom?.data?.yestday_amount.toString()
    }

    override fun onFailure(e: Throwable?, code: Int, msg: String?, isNetWorkError: Boolean) {

    }
}